<form method="post" action="">
    <div class="box grid_12">
        <div class="block" style="min-height: 610px;">
            <?php $this->load->view('partials/notices'); ?>
            <div class="input_group">
                <label>Thể loại</label> 
                <select id="object_type" name="object_type">
                    <option value="1" <?php echo ($arrObjDetail['type']==1)?'selected':''; ?>>Bài viết</option>
                    <option value="3" <?php echo ($arrObjDetail['type']==3)?'selected':''; ?>>Video</option>
                </select>
            </div>
            
            <div class="input_group">
                <label>Chuyên mục</label>
                <span>
                    <select id="list-category" name="category">
                        <option value="<?php echo $rootCategory; ?>">-- None --</option>
                        <?php
                        if(sizeof($arrCategory) > 0)
                        {
                            foreach($arrCategory as $category)
                            {
                        ?>
                                <option value="<?php echo $category['id']; ?>" <?php echo ($arrObjDetail['category_id']==$category['id'])?'selected':''; ?>><?php echo $category['title']; ?></option>
                        <?php
                            }
                        }
                        ?>
                    </select>
                </span>
                <span>
                    <a href="javascript:;" onclick="addCategory(<?php echo $rootCategory; ?>, 'list-category')">[+]Thêm chuyên mục</a>
                </span>
            </div>
            
            <label>Tiêu đề bài viết</label> 
            <input title="Nhập tiêu đề bài viết" type="text" id="title" name="title" class="large" value="<?php echo $arrObjDetail['title']; ?>"> 
            
            <label>Mô tả bài viết</label> 
            <textarea id="intro" name="intro" style="width: 100%; height: 50px;"><?php echo $arrObjDetail['intro']; ?></textarea>

            <div id="article_content" style="display: <?php echo ($arrObjDetail['type']==1)?'block':'none'; ?>;">
                <label>Nội dung bài viết</label> 
                <textarea id="content" name="content" style="width: 100%; height: 290px;"><?php echo $arrObjDetail['body']; ?></textarea>
            </div>
            
            <div id="video_content" style="display: <?php echo ($arrObjDetail['type']==3)?'block':'none'; ?>; min-height: 200px; border-bottom: 1px solid #CCC;">
                <label>Upload video</label>
                <div class="buttonHolder" style="width: 160px;">
                    <span id="spanVideoButtonPlaceholder"></span>
                </div>
                <div id="divVideoProgressContainer"></div>
                <input type="hidden" id="video_url" name="video_url" value="<?php echo $arrObjDetail['video_url']; ?>" />
                <div id="video_player" class="video_player">
                    <?php if(!empty($arrObjDetail['video_url'])) { ?>
                    <a id="player" href="<?php echo base_url().$arrObjDetail['video_url']; ?>" style="display:block;width:520px;height:330px"></a>
                    <?php } ?>
                </div>
            </div>
            
            <br/>
            <button style="clear: none;"><img height="24" width="24" src="<?php echo base_url(); ?>/static/backend/images/icons/small/white/Bended%20Arrow%20Up.png"><span>Lưu thay đổi</span></button>
            <button style="clear: none;"><img height="24" width="24" src="<?php echo base_url(); ?>/static/backend/images/icons/small/white/List%20w_%20Images.png"><span>Xem trước</span></button>
        </div>
    </div>
    <div class="box grid_4">
        <div class="block form_option">
            <div class="thumbnail">
                <img id="thumbnail" width="100%" src="<?php echo $arrObjDetail['thumb']; ?>" title="Hình đại diện" alt="Hình đại diện"/>
                <input type="hidden" id="thumbnail_url" name="thumbnail_url" value="<?php echo $arrObjDetail['thumb']; ?>" />
            </div>
            <label>Upload hình đại diện</label> 
            <div class="buttonHolder">
                <span id="spanButtonPlaceholder"></span>
            </div>
            <div id="divFileProgressContainer"></div>
            <br/>
            <div class="input_group">
                <label>Từ khóa liên quan</label>
                <textarea name="keywords" title="Nhập từ khóa liên quan đến bài viết" style="width: 100%; height: 30px;"><?php echo isset($arrObjDetail['keywords'])?$arrObjDetail['keywords']:''; ?></textarea>
            </div>
            
            <div class="input_group">
                <label>Cho phép bình luận</label>
                <select name="comment">
                    <option value="0" <?php echo (!$arrObjDetail['comments_enabled'])?'selected':''; ?>>Không</option>
                    <option value="1" <?php echo ($arrObjDetail['comments_enabled'])?'selected':''; ?>>Có</option>
                </select>
            </div>
            
            <div class="input_group">
                <label>Tình trạng</label>
                <select name="status">
                    <option value="1" <?php echo ($arrObjDetail['status'])?'selected':''; ?>>Bản chính</option>
                    <option value="0" <?php echo (!$arrObjDetail['status'])?'selected':''; ?>>Bản nháp</option>
                </select>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/nicEdit/nicEdit.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/SWFUpload/swfupload.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/SWFUpload/fileprogress.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/SWFUpload/handlers.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/flowplayer/flowplayer-3.2.8.min.js"></script>
<script type="text/javascript">
    new nicEditor({maxHeight : 300}).panelInstance('content');
    
    var swfu, swfu2;
    window.onload = function () {
            swfu = new SWFUpload({
                    // Backend Settings
                    upload_url: base_url + "upload.php",
                    post_params: {
                        "PHPSESSID": "<?php echo session_id(); ?>",
                        "folder": "/uploads/images/"
                    },
                    // File Upload Settings
                    file_size_limit : "2 MB",	// 2MB
                    file_types : "*.jpg; *.gif; *.png",
                    file_types_description : "Images files",
                    // Event Handler Settings - these functions as defined in Handlers.js
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadSuccess,
                    upload_complete_handler : uploadComplete,
                    // Button Settings
                    button_image_url : st_url + "/backend/js/SWFUpload/images/SmallSpyGlassWithTransperancy_17x18.png",
                    button_placeholder_id : "spanButtonPlaceholder",
                    button_width: 180, button_height: 18,
                    button_text : '<span class="button">Chọn ảnh <span class="buttonSmall">(2 MB Max)</span></span>',
                    button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; color: #FFFFFF; } .buttonSmall { font-size: 10pt; }',
                    button_text_top_padding: 0, button_text_left_padding: 18, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND,
                    button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
                    // Flash Settings
                    flash_url : st_url + "/backend/js/SWFUpload/swfupload.swf",
                    // Custom Settings
                    custom_settings : {
                        upload_target : "divFileProgressContainer",
                        input_target: 'thumbnail_url'
                    },
                    // Debug Settings
                    debug: false
            });
            
            swfu2 = new SWFUpload({
                    // Backend Settings
                    upload_url: base_url + "uploadfiles.php",
                    post_params: {
                        "PHPSESSID": "<?php echo session_id(); ?>",
                        "folder": "/uploads/videos/"
                    },
                    // File Upload Settings
                    file_size_limit : "100 MB",	// 2MB
                    file_types : "*.*",
                    file_types_description : "Videos files",
                    // Event Handler Settings - these functions as defined in VideoHandlers.js
                    file_queue_error_handler : fileQueueError,
                    file_dialog_complete_handler : fileDialogComplete,
                    upload_progress_handler : uploadVideoProgress,
                    upload_error_handler : uploadError,
                    upload_success_handler : uploadVideoSuccess,
                    upload_complete_handler : uploadComplete,
                    // Button Settings
                    button_image_url : st_url + "/backend/js/SWFUpload/images/SmallSpyGlassWithTransperancy_17x18.png",
                    button_placeholder_id : "spanVideoButtonPlaceholder",
                    button_width: 180, button_height: 18,
                    button_text : '<span class="button">Chọn video <span class="buttonSmall">(100 MB Max)</span></span>',
                    button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; color: #FFFFFF; } .buttonSmall { font-size: 10pt; }',
                    button_text_top_padding: 0, button_text_left_padding: 18, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND,
                    button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE,
                    // Flash Settings
                    flash_url : st_url + "/backend/js/SWFUpload/swfupload.swf",
                    // Custom Settings
                    custom_settings : {
                        progressTarget : "divVideoProgressContainer",
                        input_target: 'video_url',
                        player_target: 'video_player',
                        progressDisplay: true
                    },
                    // Debug Settings
                    debug: false
            });
    };
    
    $(document).ready(function(){
        $('#object_type').change(function(){
            if($(this).val() == 1){
                $('#video_content').hide();
                $('#article_content').show();
            }else{
                $('#article_content').hide();
                $('#video_content').show();
            }
        });
        
        <?php if(!empty($arrObjDetail['video_url'])) { ?>
        flowplayer("player", st_url + "/backend/js/flowplayer/flowplayer-3.2.9.swf", {
            clip:  {
              autoPlay: false,
              autoBuffering: true
            }
        });
        <?php } ?>
    });
</script>